package com.example.administrator.puzzlepic.com.xiaoxu.util;

import android.content.Context;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;

/**
 * Created by Administrator on 2016/4/5.
 */
public class ScreenUtil  {

    /**
     * 获取屏幕宽高*/
    public static DisplayMetrics getScreenSize(Context context){

        DisplayMetrics metrics = new DisplayMetrics();
        WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
        Display display = wm.getDefaultDisplay();

        display.getMetrics(metrics);
        return metrics;
    }


    /**
     * 获取屏幕的密度
     * */
    public static float getDeviceDensity(Context context){

        DisplayMetrics metrics = new DisplayMetrics();
        WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
        wm.getDefaultDisplay().getMetrics(metrics);

        return  metrics.density;
    }
}
